package com.liangge.essaysite.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;

public class CfgUtils {
	private static Map<String,Configuration> configMap = new HashMap<String,Configuration>();
	/**
	 * 获取common配置项
	 * @author liangge
	 */
	public static synchronized Configuration getCommonCfg(){
		return getCfg("common.properties");
	}
	
	private static synchronized Configuration getCfg(String filename){
		if(configMap.containsKey(filename)){
			return configMap.get(filename);
		}
		PropertiesConfiguration config = new PropertiesConfiguration();
		try{
			config.load(filename);
		}catch(Exception e){
			e.printStackTrace();
		}
		configMap.put(filename, config);
		return config;
	}
}
